<?php

// Include the Loader class
require_once('includes/libraries/loader.inc');

#### BASE CLASS ################################################################
class Base extends Loader {

	#### CONSTRUCTOR ###########################################################
	function Base() {

		// Allow usage of our loader class with $this->load->model('downloads')
		// making the downloads model accessible via $this->downloads->method();
		$this->load =& $this;

		// Include framework config settings
		require('includes/config/framework.inc');

		// Include helper used by loader
		$this->load->helper('method');
	}

	#### GET INSTANCE ##########################################################
	// The magic that makes our Base class a singleton even in PHP4 ^_^
	function &getInstance() {
		static $instance = null;
		if (null === $instance) {
			$instance = new Base();
		}
		return $instance;
	}

	#### GET THIS ##############################################################
	// A function used by classes to make certain objects available to them under $this
	function getThis() {

		$base =& Base::getInstance();

		// Set session reference
		$base->sessvar =& $_SESSION['lf'];

		// When we logout sessvar['login'] would normally get lost
		// Set it to NULL to prevent errors
		if (!isset($_SESSION['lf']['login'])) $base->sessvar['login'] = NULL;

		$this->load =& $base->load;
		$this->config =& $base->config;
		$this->common =& $base->common;
		$this->session =& $base->session;
		$this->sessvar =& $base->sessvar;
		$this->post =& $base->post;
		$this->page =& $base->page;
		$this->step =& $base->step;
		$this->submit =& $base->submit;
		$this->file =& $base->file;
		$this->confirm =& $base->confim;
		$this->db =& $base->db;
		$this->db_connection =& $base->db_connection;
		$this->icon =& $base->icon;
		// Array for less common variables e.g. $this->var['module_name'];
		$this->var =& $base->var;

		return $base;
	}

}

?>